***********************************************************************************************
********THE HIDDEN COSTS OF DISMISSAL: BEHAVIORAL CONSEQUENCES OF IMPENDING TERMINATION********
***********************************************************************************************
*****THIS SCRIPT REPLICATES ALL TABLES AND FIGURES IN THE ORDER OF APPEARANCE IN THE PAPER*****
***********************************************************************************************

clear all
set more off

**# PRELIMINARIES

**## Install commands

*Install user-written packages required for execution:
local packages "personage reghdfe ftools addplot did_imputation"
foreach x of local packages {
	capture ssc install `x'
}

**## Load data
use "dismissal", clear

**## Event study design variables

*Relative time to event:
gen reltime = date-exitnotedat
label variable reltime "# Days since notice"

*Minimum and maximum relative time per employee:
bys empid: egen reltime_min=min(reltime)
bys empid: egen reltime_max=max(reltime)

*Define maximum number of leads and lags considered:
global lead_max 120
global lag_max 30

*Leads and lags:
forval i=-$lead_max/$lag_max {
    qui {
		if `i'<0 {
			local j=`i'*-1
			gen lead_`j'=reltime==`i' if !mi(reltime)
		}
		else {
			gen lag_`i'=reltime==`i' if !mi(reltime)
		}
	}
}

*Define anticipatory and longer-run effects (binned together):
gen lead_bin = reltime < -$lead_max
order lead_bin, b(lead_$lead_max)
gen lag_bin = reltime > $lag_max
order lag_bin, a(lag_$lag_max)

*Define shift (for all types of termination):
global shift 60

**## Sample restrictions

**### Define restrictions on included employees

*Do not include...

*... store managers:
local sub_cond1 manager!=1
*... reasons for leaving that apply only to managers:
local sub_cond2 exitrea2!=22
*... employees with inactive employment relationships:
local sub_cond3 anyinact==0
*... employees who are not employed at least one day before and after the notice date:
local sub_cond4 reltime_min<=-1 & reltime_max>=1
*... employees who are not dismissed, do not resign and do not conclude a mutual termination agreement:
local sub_cond5 inlist(exitcat,1,2,3)
*... employees whose employment relationship is not terminated due to person-related or family-related reasons:
local sub_cond6 inlist(exitrea,6,8)
*... health-related reasons for leaving:
local sub_cond7 !inlist(exitrea2,3,10,20)

global sub `sub_cond1' & `sub_cond2' & `sub_cond3' & `sub_cond4' & `sub_cond5' & `sub_cond6' & `sub_cond7'

*Define subsample of employees whose employment relationship is not terminated during the observation period:

*Do not include...

*... store managers:
local substay_cond1 manager!=1
*... employees with inactive employment relationships:
local substay_cond2 anyinact==0
*... employees whose employment relationship is terminated:
local substay_cond3 mi(exitcat)

global substay `substay_cond1' & `substay_cond2' & `substay_cond3'

**### Define restrictions on included observations

*Define included observations:

*Require at least 50 observations per period:
local obsmin 50

*Find minimum and maximum relative time satisfying the condition for each type of termination:
local mins ""
local maxs ""

forval i=1/3 {
	qui levelsof reltime if $sub & exitcat==`i', matrow(A`i') matcell(B`i')
	local colmax`i' `r(r)'
	mat C`i' = A`i',B`i'
	
	*Initialize:
	local values`i' ""
	local min`i' 0
	local max`i' 0
	
	forval j=1/`colmax`i'' {
		if C`i'[`j',2] >= `obsmin' {
			local value`i'`j' = C`i'[`j',1]
			local values`i' `values`i'' `value`i'`j''
		}
	}
	*Find minimum and maximum:
	local len`i' : word count `values`i''
	forval k=1/`len`i'' {
		local value `: word `k' of `values`i'`j'''
		if `value' < `min`i'' {
			local min`i' = `value'
		}
		if `value' > `max`i'' {
			local max`i' = `value'
		}
	}
	local mins `mins' `min`i''
	local maxs `maxs' `max`i''
}

*Find minimum and maximum relative time satisfying the condition for all types of termination:

*Initialize:
local reltime_lb: word 1 of `mins'
local reltime_ub: word 1 of `maxs'

forval i=2/3 {
	local min `: word `i' of `mins''
	local max `: word `i' of `maxs''
	if `min' > `reltime_lb' {
		local reltime_lb = `min'
	}
	if `max' < `reltime_ub' {
		local reltime_ub = `max'
	}
}

global reltime_lb `reltime_lb'
global reltime_ub `reltime_ub'
global reltime_bw inrange(reltime,$reltime_lb,$reltime_ub)

**## Employee characteristics

*Age:
qui personage bdat exitnotedat, gen(age)
*Adjust for stayers:
personage bdat, currdate(mdy(12,31,2019)) gen(age2)
qui replace age=age2 if $substay
drop age2

*Female:
qui gen female=0 if !mi(gender)
qui replace female=1 if gender==2
order female, a(gender)

*Civil partnership:
gen cipa = inlist(family,1,5)
label variable cipa "Civil partnership"

*Tenure:
personage entry_acc exitnotedat, gen(tenure)
*In months:
gen tenure_m = datediff(entry_acc,exitnotedat,"month")
*Adjust tenure for stayers:
personage entry_acc, currdate(mdy(12,31,2019)) gen(tenure2)
replace tenure=tenure2 if $substay
drop tenure2
gen tenure2_m = datediff(entry_acc,mdy(12,31,2019),"month")
replace tenure_m=tenure2_m if $substay
drop tenure2_m

*Notice period:

*Probationary period:
gen probend = dofm(mofd(entry_acc)+6)+day(entry_acc)-1
format probend %td
gen exitinprob = exitnotedat<=probend

*Legal notice period:
gen noteper_leg = .
replace noteper_leg = 28 if inlist(exitcat,1,2)
replace noteper_leg = 14 if exitinprob==1
replace noteper_leg = 30 if tenure>=2 & exitcat==1
replace noteper_leg = 60 if tenure>=5 & exitcat==1
replace noteper_leg = 90 if tenure>=8 & exitcat==1
replace noteper_leg = 120 if tenure>=10 & exitcat==1
replace noteper_leg = 150 if tenure>=12 & exitcat==1
replace noteper_leg = 180 if tenure>=15 & exitcat==1
replace noteper_leg = 210 if tenure>=20 & exitcat==1
replace noteper_leg = 0 if exitcat==3
*Actual notice period: days between notice date and leaving date:
gen noteper_act = exitdat-exitnotedat
*Difference:
gen noteper_delta = noteper_act-noteper_leg

*Prior absenteeism:
qui bys empid: egen absence_prior = mean(sick) if inrange(reltime,$reltime_lb,-$shift-1)
gsort empid -absence_prior
qui replace absence_prior = absence_prior[_n-1] if empid == empid[_n-1]
sort empid date
*Adjust for stayers:
qui bys empid: egen absence_prior2 = mean(sick)
gsort empid -absence_prior2
qui replace absence_prior2 = absence_prior2[_n-1] if empid == empid[_n-1]
sort empid date
replace absence_prior=absence_prior2 if $substay
drop absence_prior2

**# RESULTS

**## Paper

**### Table 1: Employee Characteristics by Type of Termination

tabstat age female cipa tenure_m noteper_leg noteper_act if $sub & unique==1, statistics(mean sd min max p50 n) columns(statistics) by(exitcat) nototal long

**### Figure 2: Absenteeism Around the Date of Notice

preserve

keep if $sub & inrange(reltime,-$lead_max,$lag_max)

collapse sick, by(reltime exitcat)

keep if mod(reltime,10)==0

tw connected sick reltime if exitcat==1, mcolor(black) msymb(circle) msize(large) lc(black) lp(solid) lw(thick) || ///
connected sick reltime if exitcat==2, mcolor(black) msymb(square)  msize(large) lc(black) lp(shortdash) lw(thick) || ///
connected sick reltime if exitcat==3, mcolor(black) msymb(triangle) msize(large) lc(black) lp(longdash) lw(thick) ///
xline(0,lc(black) lp(dash)) ///
yline(0(0.1)0.6,lc(black) lp(dot)) ///
legend(order (1 2 3) label(1 "Dismissal by employer") label(2 "Resignation by employee") label(3 "Mutual termination agreement") rows(3) ring(0) pos(11)) ///
xtitle("Days since notice", margin(small)) ///
ytitle("Share of employees absent", margin(small)) ///
xlab(-$lead_max(10)$lag_max, labsize(small)) ///
ylab(0 "0" 0.1 "0.1" 0.2 "0.2" 0.3 "0.3" 0.4 "0.4" 0.5 "0.5" 0.6 "0.6", labsize(small) nogrid) ///
scheme(s1mono) ///
xsize(5) ///
ysize(4) ///
graphregion(margin(l=0 b=0))

restore

**### Figure 3: Effect of Notice of Termination on Absenteeism

*Define included leads and lags:
local j = 1 + $shift
local omit lead_`j'

global leadslags ""
foreach var of varlist lead_* lag_* {
	if "`var'"=="`omit'" {
		global leadslags $leadslags o.`var'
	}
	else {
		global leadslags $leadslags `var'
	}
}

forval i=1/3 {
	
	qui reghdfe sick $leadslags if $sub & $reltime_bw & reltime_min<-$shift-1 & exitcat==`i', absorb(empid date) vce(cluster ccenter) noconstant
	
	*Individual coefficients:
	mat A = r(table)
	mat B = (A["b",1...]\A["ll",1...]\A["ul",1...])'
	
	mat C = J(`= rowsof(B)',1,`i')
	mat colnames C = exitcat
	
	mat D`i' = B,C
	
	*Combined coefficients:
	
	*Anticipation effects:
	local anti_cofs "lead_$shift"
	local anti_cofs_cnt 1
	local max = $shift - 1
	forval j=`max'(-1)1 {
		local anti_cofs `anti_cofs' + lead_`j'
		local anti_cofs_cnt = `anti_cofs_cnt'+1
	}
	qui lincom (`anti_cofs')/`anti_cofs_cnt'
	mat E`i'_anti = r(estimate), r(lb), r(ub), -30, `i'

	*Treatment effects:
	local treat_cofs "lag_0"
	local treat_cofs_cnt 1
	forval j=1/$lag_max {
		local treat_cofs `treat_cofs' + lag_`j'
		local treat_cofs_cnt = `treat_cofs_cnt'+1
	}
	
	qui lincom (`treat_cofs')/`treat_cofs_cnt'
	mat E`i'_treat = r(estimate), r(lb), r(ub), 15, `i'
	
	mat E`i' = E`i'_anti\E`i'_treat
	
}

*Combine:

*Individual coefficients:
mat D = D1\D2\D3
*Combined coefficients:
mat E=E1\E2\E3
mat colnames E = b ll ul x exitcat

*Figure:

preserve

clear

svmat D, names(col)

bys exitcat: gen x = (_n-1) - ($lead_max + 1)

label define exitcat_label 1 "Dismissal" 2 "Resignation" 3 "Agreement"
label values exitcat exitcat_label

tw (rarea ll ul x, color(gs12) lwidth(none)) || ///
(line b x, lc(gs6)), ///
by(exitcat, rows(1) note("")) ///
subtitle(,lc(none) fc(none)) ///
xtitle("Days since notice", margin(small)) ///
ytitle("Coefficient estimates" "({&Delta} Probability of being absent)", margin(small)) ///
xlab(-$lead_max(30)$lag_max, labsize(small)) ///
xsc(range(-121 31)) ///
ysc(range(-0.4 0.6)) ///
ylab(, labsize(small)) ///
ylab(-0.4(0.1)-0.1, format(%2.1fc) custom add) ///
ylab(0 "±0", custom add) ///
ylab(0.1 "+0.1" 0.2 "+0.2" 0.3 "+0.3" 0.4 "+0.4" 0.5 "+0.5" 0.6 "+0.6", format(%2.1fc) custom add) ///
xline(-$shift 0, lp(dash)) ///
yline(0, lp(dash) lc(black)) ///
yline(-0.4(0.1)-0.1 0.1(0.1)0.6, lp(dot)) ///
scheme(s1mono) ///
xsize(5) ///
ysize(4) ///
graphregion(margin(l=0 b=0)) ///
name(g1, replace)

clear

svmat E, names(col)

addplot g1 1: (scatter b x if exitcat==1, msymb(circle) color(black) msize(small)) (rcap ll ul x if exitcat==1, color(black)), norescaling
addplot g1 2: (scatter b x if exitcat==2, msymb(circle) color(black) msize(small)) (rcap ll ul x if exitcat==2, color(black)), norescaling
addplot g1 3: (scatter b x if exitcat==3, msymb(circle) color(black) msize(small)) (rcap ll ul x if exitcat==3, color(black)), norescaling
addplot g1: , legend(order(3 "Linear combination of coefficient estimates") size(small)) norescaling

restore

**### Figure 4: Effect of Notice of Termination on Absenteeism by Unemployment Rate

*Split by unemployment rate:

*Local unemployment rate at time of notice:
qui gen unemp_notice = unemp if reltime==0
gsort empid -unemp_notice
qui replace unemp_notice = unemp_notice[_n-1] if empid == empid[_n-1]
sort empid date
*Median split:
qui gen high_unemp_notice = 0 if !mi(unemp_notice)
qui sum unemp_notice if $sub & reltime_min<-$shift-1 & unique==1, detail
di `r(p50)'
di `r(mean)'
di `r(sd)'
di `r(min)'
di `r(max)'
qui replace high_unemp_notice = 1 if unemp_notice > `r(p50)' & !mi(unemp_notice)

forval i=1/3 {
	forval k=0/1 {
	
		qui reghdfe sick $leadslags if $sub & $reltime_bw & reltime_min<-$shift-1 & high_unemp_notice==`k' & exitcat==`i', absorb(empid date) vce(cluster ccenter) noconstant
		
		*Individual coefficients:
		mat A = r(table)
		mat B = (A["b",1...]\A["ll",1...]\A["ul",1...])'
		
		mat C = J(`= rowsof(B)',1,`i')
		mat colnames C = exitcat
		mat D = J(`= rowsof(B)',1,`k')
		mat colnames D = high
		
		mat E_`i'_`k' = B,C,D
		
		*Combined coefficients:
		
		*Anticipation effects:
		local anti_cofs "lead_$shift"
		local anti_cofs_cnt 1
		local max = $shift - 1
		forval j=`max'(-1)1 {
			local anti_cofs `anti_cofs' + lead_`j'
			local anti_cofs_cnt = `anti_cofs_cnt'+1
		}
		qui lincom (`anti_cofs')/`anti_cofs_cnt'
		mat F_`i'_`k'_anti = r(estimate), r(lb), r(ub), -30, `i', `k'

		*Treatment effects:
		local treat_cofs "lag_0"
		local treat_cofs_cnt 1
		forval j=1/$lag_max {
			local treat_cofs `treat_cofs' + lag_`j'
			local treat_cofs_cnt = `treat_cofs_cnt'+1
		}
		
		qui lincom (`treat_cofs')/`treat_cofs_cnt'
		mat F_`i'_`k'_treat = r(estimate), r(lb), r(ub), 15, `i', `k'
		
		mat F_`i'_`k' = F_`i'_`k'_anti\F_`i'_`k'_treat
		
	}
	
}

*Combine:

*Individual coefficients:
mat E = E_1_0\E_1_1\E_2_0\E_2_1\E_3_0\E_3_1
*Combined coefficients:
mat F = F_1_0\F_1_1\F_2_0\F_2_1\F_3_0\F_3_1
mat colnames F = b ll ul x exitcat high

*Figure:

preserve

clear

svmat E, names(col)

bys exitcat high: gen x = (_n-1) - ($lead_max + 1)

label define exitcat_label 1 "Dismissal" 2 "Resignation" 3 "Agreement"
label values exitcat exitcat_label

tw (rarea ll ul x if high==0, color(orange%50) lwidth(none)) ///
	(line b x if high==0, lc(orange*1.5)) ///
	(rarea ll ul x if high==1, color(midblue%50) lwidth(none)) ///
	(line b x if high==1, lc(midblue*1.5)), ///
	by(exitcat, rows(1) note("")) ///
	subtitle(,lc(none) fc(none)) ///
	xtitle("Days since notice", margin(small)) ///
	ytitle("Coefficient estimates" "({&Delta} Probability of being absent)", margin(small)) ///
	xlab(-$lead_max(30)$lag_max, labsize(small)) ///
	xsc(range(-121 31)) ///
	ysc(range(-0.5 0.7)) ///
	ylab(-0.5 "-0.5" -0.4 "-0.4" -0.3 "-0.3" -0.2 "-0.2" -0.1 "-0.1" 0 "±0" 0.1 "+0.1" 0.2 "+0.2" 0.3 "+0.3" 0.4 "+0.4" 0.5 "+0.5" 0.6 "+0.6" 0.7 "+0.7", labsize(vsmall)) ///
	xline(-$shift 0, lp(dash)) ///
	yline(0, lp(dash) lc(black)) ///
	yline(-0.5(0.1)-0.1 0.1(0.1)0.7, lp(dot)) ///
	scheme(s1mono) ///
	xsize(5) ///
	ysize(4) ///
	graphregion(margin(l=0 b=0)) ///
	name(g1, replace)
	
clear

svmat F, names(col)

*Shift position of markers:
replace x=x-5 if high==0
replace x=x+5 if high==1

addplot g1 1: (rcap ll ul x if exitcat==1 & high==0, color(black)) (scatter b x if exitcat==1 & high==0, msymb(circle) mlc(black) mfc(orange*1.5) msize(small)) (rcap ll ul x if exitcat==1 & high==1, color(black)) (scatter b x if exitcat==1 & high==1, msymb(circle) mlc(black) mfc(midblue*1.5) msize(small)), norescaling
addplot g1 2: (rcap ll ul x if exitcat==2 & high==0, color(black)) (scatter b x if exitcat==2 & high==0, msymb(circle) mlc(black) mfc(orange*1.5) msize(small)) (rcap ll ul x if exitcat==2 & high==1, color(black)) (scatter b x if exitcat==2 & high==1, msymb(circle) mlc(black) mfc(midblue*1.5) msize(small)), norescaling
addplot g1 3: (rcap ll ul x if exitcat==3 & high==0, color(black)) (scatter b x if exitcat==3 & high==0, msymb(circle) mlc(black) mfc(orange*1.5) msize(small)) (rcap ll ul x if exitcat==3 & high==1, color(black)) (scatter b x if exitcat==3 & high==1, msymb(circle) mlc(black) mfc(midblue*1.5) msize(small)), norescaling
addplot g1: , legend(order(6 "Linear combination of coefficient estimates" - " " 1 "Low unemployment rate" 3 "High unemployment rate") size(small)) norescaling

restore

**### Figure 5: Effect of Notice of Termination on Absenteeism by Initiating Party

**#### Panel A: Termination Initiated by Employer

forval i=1(2)3 {
	
	qui reghdfe sick $leadslags if $sub & $reltime_bw & reltime_min<-$shift-1 & exitcat==`i' & exitrea==8, absorb(empid date) vce(cluster ccenter) noconstant
	
	*Individual coefficients:
	mat A = r(table)
	mat B = (A["b",1...]\A["ll",1...]\A["ul",1...])'
	
	mat C = J(`= rowsof(B)',1,`i')
	mat colnames C = exitcat
	
	mat D`i' = B,C
	
	*Combined coefficients:
	
	*Anticipation effects:
	local anti_cofs "lead_$shift"
	local anti_cofs_cnt 1
	local max = $shift - 1
	forval j=`max'(-1)1 {
		local anti_cofs `anti_cofs' + lead_`j'
		local anti_cofs_cnt = `anti_cofs_cnt'+1
	}
	qui lincom (`anti_cofs')/`anti_cofs_cnt'
	mat E`i'_anti = r(estimate), r(lb), r(ub), -30, `i'

	*Treatment effects:
	local treat_cofs "lag_0"
	local treat_cofs_cnt 1
	forval j=1/$lag_max {
		local treat_cofs `treat_cofs' + lag_`j'
		local treat_cofs_cnt = `treat_cofs_cnt'+1
	}
	
	qui lincom (`treat_cofs')/`treat_cofs_cnt'
	mat E`i'_treat = r(estimate), r(lb), r(ub), 15, `i'
	
	mat E`i' = E`i'_anti\E`i'_treat
	
}

*Combine:

*Individual coefficients:
mat D = D1\D3
*Combined coefficients:
mat E =E1\E3
mat colnames E = b ll ul x exitcat

*Figure:

preserve

clear

svmat D, names(col)

bys exitcat: gen x = (_n-1) - ($lead_max + 1)

label define exitcat_label 1 "Dismissal" 3 "Agreement"
label values exitcat exitcat_label

tw (rarea ll ul x, color(gs12) lwidth(none)) || ///
(line b x, lc(gs6)), ///
by(exitcat, rows(1) note("") scale(1.3)) ///
subtitle(,lc(none) fc(none)) ///
xtitle("Days since notice", margin(small)) ///
ytitle("Coefficient estimates" "({&Delta} Probability of being absent)", margin(small)) ///
xlab(-$lead_max(30)$lag_max, labsize(small)) ///
xsc(range(-121 31)) ///
ysc(range(-1.2 0.6)) ///
ylab(-1.2 "-1.2" -1 "-1" -0.8 "-0.8" -0.6 "-0.6" -0.4 "-0.4" -0.2 "-0.2" 0 "±0" 0.2 "+0.2" 0.4 "+0.4" 0.6 "+0.6", labsize(vsmall)) ///
xline(-$shift 0, lp(dash)) ///
yline(0, lp(dash) lc(black)) ///
yline(-1.2(0.2)-0.2 0.2(0.2)0.6, lp(dot)) ///
scheme(s1mono) ///
xsize(5) ///
ysize(2) ///
graphregion(margin(l=0 b=0)) ///
name(g1, replace)

clear

svmat E, names(col)

addplot g1 1: (scatter b x if exitcat==1, msymb(circle) color(black) msize(small)) (rcap ll ul x if exitcat==1, color(black)), norescaling
addplot g1 2: (scatter b x if exitcat==3, msymb(circle) color(black) msize(small)) (rcap ll ul x if exitcat==3, color(black)), norescaling
addplot g1: , legend(order(3 "Linear combination of coefficient estimates") size(small)) norescaling

restore

**#### Panel B: Termination Initiated by Employee

forval i=2/3 {
	
	qui reghdfe sick $leadslags if $sub & $reltime_bw & reltime_min<-$shift-1 & exitcat==`i' & exitrea==6, absorb(empid date) vce(cluster ccenter) noconstant
	
	*Individual coefficients:
	mat A = r(table)
	mat B = (A["b",1...]\A["ll",1...]\A["ul",1...])'
	
	mat C = J(`= rowsof(B)',1,`i')
	mat colnames C = exitcat
	
	mat D`i' = B,C
	
	*Combined coefficients:
	
	*Anticipation effects:
	local anti_cofs "lead_$shift"
	local anti_cofs_cnt 1
	local max = $shift - 1
	forval j=`max'(-1)1 {
		local anti_cofs `anti_cofs' + lead_`j'
		local anti_cofs_cnt = `anti_cofs_cnt'+1
	}
	qui lincom (`anti_cofs')/`anti_cofs_cnt'
	mat E`i'_anti = r(estimate), r(lb), r(ub), -30, `i'

	*Treatment effects:
	local treat_cofs "lag_0"
	local treat_cofs_cnt 1
	forval j=1/$lag_max {
		local treat_cofs `treat_cofs' + lag_`j'
		local treat_cofs_cnt = `treat_cofs_cnt'+1
	}
	
	qui lincom (`treat_cofs')/`treat_cofs_cnt'
	mat E`i'_treat = r(estimate), r(lb), r(ub), 15, `i'
	
	mat E`i' = E`i'_anti\E`i'_treat
	
}

*Combine:

*Individual coefficients:
mat D = D2\D3
*Combined coefficients:
mat E =E2\E3
mat colnames E = b ll ul x exitcat

*Figure:

preserve

clear

svmat D, names(col)

bys exitcat: gen x = (_n-1) - ($lead_max + 1)

label define exitcat_label 2 "Resignation" 3 "Agreement"
label values exitcat exitcat_label

tw (rarea ll ul x, color(gs12) lwidth(none)) || ///
(line b x, lc(gs6)), ///
by(exitcat, rows(1) note("") scale(1.3)) ///
subtitle(,lc(none) fc(none)) ///
xtitle("Days since notice", margin(small)) ///
ytitle("Coefficient estimates" "({&Delta} Probability of being absent)", margin(small)) ///
xlab(-$lead_max(30)$lag_max, labsize(small)) ///
xsc(range(-121 31)) ///
ysc(range(-1.2 0.6)) ///
ylab(-1.2 "-1.2" -1 "-1" -0.8 "-0.8" -0.6 "-0.6" -0.4 "-0.4" -0.2 "-0.2" 0 "±0" 0.2 "+0.2" 0.4 "+0.4" 0.6 "+0.6", labsize(vsmall)) ///
xline(-$shift 0, lp(dash)) ///
yline(0, lp(dash) lc(black)) ///
yline(-1.2(0.2)-0.2 0.2(0.2)0.6, lp(dot)) ///
scheme(s1mono) ///
xsize(5) ///
ysize(2) ///
graphregion(margin(l=0 b=0)) ///
name(g1, replace)

clear

svmat E, names(col)

addplot g1 1: (scatter b x if exitcat==2, msymb(circle) color(black) msize(small)) (rcap ll ul x if exitcat==2, color(black)), norescaling
addplot g1 2: (scatter b x if exitcat==3, msymb(circle) color(black) msize(small)) (rcap ll ul x if exitcat==3, color(black)), norescaling
addplot g1: , legend(order(3 "Linear combination of coefficient estimates") size(small)) norescaling

restore

**## Appendix

**### Table A1: Employee Characteristics by Group of Employees

*Define sample:
qui gen sample=1 if $sub
qui replace sample=2 if $substay

tabstat age female cipa tenure_m noteper_leg noteper_act if unique==1, statistics(mean sd min max p50 n) columns(statistics) by(sample) nototal long

**### Table A2: Determinants of Absenteeism by Group of Employees

reg absence_prior age female cipa tenure_m if unique==1 & $sub & exitcat==1, vce(cluster ccenter)
reg absence_prior age female cipa tenure_m if unique==1 & $sub & exitcat==2, vce(cluster ccenter)
reg absence_prior age female cipa tenure_m if unique==1 & $sub & exitcat==3, vce(cluster ccenter)
reg absence_prior age female cipa tenure_m if unique==1 & $substay, vce(cluster ccenter)

**### Table A3: Determinants of Mutual Termination Agreement by Initiating Party

*Indicator of mutual termination agreement for cases in which termination was initiated by the employer and employee, respectively:
gen mta_employer = exitcat==3 if exitrea==8
gen mta_employee = exitcat==3 if exitrea==6

reg mta_employer absence_prior age female cipa tenure_m if unique==1 & $sub, vce(cluster ccenter)
reg mta_employee absence_prior age female cipa tenure_m if unique==1 & $sub, vce(cluster ccenter)

**### Figure A1: Effect of Notice of Termination on Absenteeism (Imputation Method)

/*
*Dismissal:
did_imputation sick empid date exitnotedat if $sub & $reltime_bw & reltime_min<-$shift-1 & exitcat==1, shift(60) pretrends(60) autosample allhorizons cluster(ccenter) maxit(2000) nose
mat imput_1 = r(table)

*Resignation:
did_imputation sick empid date exitnotedat if $sub & $reltime_bw & reltime_min<-$shift-1 & exitcat==2, shift(60) pretrends(60) autosample allhorizons cluster(ccenter) maxit(2000) nose
mat imput_2 = r(table)

*Mutual terminatuon agreement:
did_imputation sick empid date exitnotedat if $sub & $reltime_bw & reltime_min<-$shift-1 & exitcat==3, shift(60) pretrends(60) autosample allhorizons cluster(ccenter) maxit(2000) nose
mat imput_3 = r(table)

*Combine:
mat imput = imput_1 \ imput_2 \ imput_3

*Figure:
capture frame drop imput
frame create imput
frame imput {

	svmat imput, names(col)

	*Order:
	order pre*, b(tau0)
	*Label:
	foreach var of varlist _all {
		label variable `var' `var'
	}
	*Rename:
	local j 1
	foreach var of varlist _all {
		
		if "`var'"=="tau0" {
			local k `j'
			di "`k'"
		}
		
		rename `var' b`j'
		local j = `j'+1
		
	}

	gen exitcat = _n

	reshape long b, i(exitcat)

	gen x = _j - `k' - $shift
	
	*Discard obsolete estimates:
	drop if x>30

	label define exitcat_label 1 "Dismissal" 2 "Resignation" 3 "Agreement"
	label values exitcat exitcat_label

	tw (line b x, lc(black) lw(thick)), ///
	by(exitcat, rows(1) note("") legend(off)) ///
	subtitle(,lc(none) fc(none)) ///
	xtitle("Days since notice", margin(small)) ///
	ytitle("Coefficient estimates" "({&Delta} Probability of being absent)", margin(small)) ///
	xlab(-$lead_max(30)$lag_max, labsize(small)) ///
	xsc(range(-121 31)) ///
	ysc(range(-0.4 0.6)) ///
	ylab(, labsize(small)) ///
	ylab(-0.4(0.1)-0.1, format(%2.1fc) custom add) ///
	ylab(0 "±0", custom add) ///
	ylab(0.1 "+0.1" 0.2 "+0.2" 0.3 "+0.3" 0.4 "+0.4" 0.5 "+0.5" 0.6 "+0.6", format(%2.1fc) custom add) ///
	xline(-$shift 0, lp(dash)) ///
	yline(0, lp(dash) lc(black)) ///
	yline(-0.4(0.1)-0.1 0.1(0.1)0.6, lp(dot)) ///
	scheme(s1mono) ///
	xsize(5) ///
	ysize(4) ///
	graphregion(margin(l=0 b=0))
	
}
*/

**### Figure A2: Effect of Notice of Termination on Absenteeism (Balanced Sample)

forval i=1/3 {
	
	qui reghdfe sick $leadslags if $sub & $reltime_bw & reltime_min<=-$lead_max & reltime_max>=$lag_max & exitcat==`i', absorb(empid date) vce(cluster ccenter) noconstant
	
	*Individual coefficients:
	mat A = r(table)
	mat B = (A["b",1...]\A["ll",1...]\A["ul",1...])'
	
	mat C = J(`= rowsof(B)',1,`i')
	mat colnames C = exitcat
	
	mat D`i' = B,C
	
	*Combined coefficients:
	
	*Anticipation effects:
	local anti_cofs "lead_$shift"
	local anti_cofs_cnt 1
	local max = $shift - 1
	forval j=`max'(-1)1 {
		local anti_cofs `anti_cofs' + lead_`j'
		local anti_cofs_cnt = `anti_cofs_cnt'+1
	}
	qui lincom (`anti_cofs')/`anti_cofs_cnt'
	mat E`i'_anti = r(estimate), r(lb), r(ub), -30, `i'

	*Treatment effects:
	local treat_cofs "lag_0"
	local treat_cofs_cnt 1
	forval j=1/$lag_max {
		local treat_cofs `treat_cofs' + lag_`j'
		local treat_cofs_cnt = `treat_cofs_cnt'+1
	}
	
	qui lincom (`treat_cofs')/`treat_cofs_cnt'
	mat E`i'_treat = r(estimate), r(lb), r(ub), 15, `i'
	
	mat E`i' = E`i'_anti\E`i'_treat
	
}

*Combine:

*Individual coefficients:
mat D = D1\D2\D3
*Combined coefficients:
mat E=E1\E2\E3
mat colnames E = b ll ul x exitcat

*Figure:

preserve

clear

svmat D, names(col)

bys exitcat: gen x = (_n-1) - ($lead_max + 1)

label define exitcat_label 1 "Dismissal" 2 "Resignation" 3 "Agreement"
label values exitcat exitcat_label

tw (rarea ll ul x, color(gs12) lwidth(none)) || ///
(line b x, lc(gs6)), ///
by(exitcat, rows(1) note("")) ///
subtitle(,lc(none) fc(none)) ///
xtitle("Days since notice", margin(small)) ///
ytitle("Coefficient estimates" "({&Delta} Probability of being absent)", margin(small)) ///
xlab(-$lead_max(30)$lag_max, labsize(small)) ///
xsc(range(-121 31)) ///
ysc(range(-0.5 0.6)) ///
ylab(,labsize(small)) ///
ylab(-0.5(0.1)-0.1, format(%2.1fc) custom add) ///
ylab(0 "±0", custom add) ///
ylab(0.1 "+0.1" 0.2 "+0.2" 0.3 "+0.3" 0.4 "+0.4" 0.5 "+0.5" 0.6 "+0.6", format(%2.1fc) custom add) ///
xline(-$shift 0, lp(dash)) ///
yline(0, lp(dash) lc(black)) ///
yline(-0.5(0.1)-0.1 0.1(0.1)0.6, lp(dot)) ///
scheme(s1mono) ///
xsize(5) ///
ysize(4) ///
graphregion(margin(l=0 b=0)) ///
name(g1, replace)

clear

svmat E, names(col)

addplot g1 1: (scatter b x if exitcat==1, msymb(circle) color(black) msize(small)) (rcap ll ul x if exitcat==1, color(black)), norescaling
addplot g1 2: (scatter b x if exitcat==2, msymb(circle) color(black) msize(small)) (rcap ll ul x if exitcat==2, color(black)), norescaling
addplot g1 3: (scatter b x if exitcat==3, msymb(circle) color(black) msize(small)) (rcap ll ul x if exitcat==3, color(black)), norescaling
addplot g1: , legend(order(3 "Linear combination of coefficient estimates") size(small)) norescaling

restore

**### Figure A3: Effect of Notice of Termination on Absenteeism by Prior Absenteeism

*Split by prior absenteeism:

*Median splits by type of termination:
qui gen high_absence_prior=0 if !mi(absence_prior)
forval i=1/3 {
	qui sum absence_prior if $sub & reltime_min<-$shift-1 & unique==1 & exitcat==`i', detail
	di `r(p50)'
	qui replace high_absence_prior=1 if exitcat==`i' & absence_prior > `r(p50)' & !mi(absence_prior)
}

forval i=1/3 {
	forval k=0/1 {
	
		qui reghdfe sick $leadslags if $sub & $reltime_bw & reltime_min<-$shift-1 & high_absence_prior==`k' & exitcat==`i', absorb(empid date) vce(cluster ccenter) noconstant
		
		*Individual coefficients:
		mat A = r(table)
		mat B = (A["b",1...]\A["ll",1...]\A["ul",1...])'
		
		mat C = J(`= rowsof(B)',1,`i')
		mat colnames C = exitcat
		mat D = J(`= rowsof(B)',1,`k')
		mat colnames D = high
		
		mat E_`i'_`k' = B,C,D
		
		*Combined coefficients:
		
		*Anticipation effects:
		local anti_cofs "lead_$shift"
		local anti_cofs_cnt 1
		local max = $shift - 1
		forval j=`max'(-1)1 {
			local anti_cofs `anti_cofs' + lead_`j'
			local anti_cofs_cnt = `anti_cofs_cnt'+1
		}
		qui lincom (`anti_cofs')/`anti_cofs_cnt'
		mat F_`i'_`k'_anti = r(estimate), r(lb), r(ub), -30, `i', `k'

		*Treatment effects:
		local treat_cofs "lag_0"
		local treat_cofs_cnt 1
		forval j=1/$lag_max {
			local treat_cofs `treat_cofs' + lag_`j'
			local treat_cofs_cnt = `treat_cofs_cnt'+1
		}
		
		qui lincom (`treat_cofs')/`treat_cofs_cnt'
		mat F_`i'_`k'_treat = r(estimate), r(lb), r(ub), 15, `i', `k'
		
		mat F_`i'_`k' = F_`i'_`k'_anti\F_`i'_`k'_treat
		
	}
	
}

*Combine:

*Individual coefficients:
mat E = E_1_0\E_1_1\E_2_0\E_2_1\E_3_0\E_3_1
*Combined coefficients:
mat F = F_1_0\F_1_1\F_2_0\F_2_1\F_3_0\F_3_1
mat colnames F = b ll ul x exitcat high

*Figure:

preserve

clear

svmat E, names(col)

bys exitcat high: gen x = (_n-1) - ($lead_max + 1)

label define exitcat_label 1 "Dismissal" 2 "Resignation" 3 "Agreement"
label values exitcat exitcat_label

tw (rarea ll ul x if high==0, color(orange%50) lwidth(none)) ///
	(line b x if high==0, lc(orange*1.5)) ///
	(rarea ll ul x if high==1, color(midblue%50) lwidth(none)) ///
	(line b x if high==1, lc(midblue*1.5)), ///
	by(exitcat, rows(1) note("")) ///
	subtitle(,lc(none) fc(none)) ///
	xtitle("Days since notice", margin(small)) ///
	ytitle("Coefficient estimates" "({&Delta} Probability of being absent)", margin(small)) ///
	xlab(-$lead_max(30)$lag_max, labsize(small)) ///
	xsc(range(-121 31)) ///
	ysc(range(-0.7 0.7)) ///
	ylab(-0.7 "-0.7" -0.6 "-0.6" -0.5 "-0.5" -0.4 "-0.4" -0.3 "-0.3" -0.2 "-0.2" -0.1 "-0.1" 0 "±0" 0.1 "+0.1" 0.2 "+0.2" 0.3 "+0.3" 0.4 "+0.4" 0.5 "+0.5" 0.6 "+0.6" 0.7 "+0.7", labsize(vsmall)) ///
	xline(-$shift 0, lp(dash)) ///
	yline(0, lp(dash) lc(black)) ///
	yline(-0.7(0.1)-0.1 0.1(0.1)0.7, lp(dot)) ///
	scheme(s1mono) ///
	xsize(5) ///
	ysize(4) ///
	graphregion(margin(l=0 b=0)) ///
	name(g1, replace)
	
clear

svmat F, names(col)

*Shift position of markers:
replace x=x-5 if high==0
replace x=x+5 if high==1

addplot g1 1: (rcap ll ul x if exitcat==1 & high==0, color(black)) (scatter b x if exitcat==1 & high==0, msymb(circle) mlc(black) mfc(orange*1.5) msize(small)) (rcap ll ul x if exitcat==1 & high==1, color(black)) (scatter b x if exitcat==1 & high==1, msymb(circle) mlc(black) mfc(midblue*1.5) msize(small)), norescaling
addplot g1 2: (rcap ll ul x if exitcat==2 & high==0, color(black)) (scatter b x if exitcat==2 & high==0, msymb(circle) mlc(black) mfc(orange*1.5) msize(small)) (rcap ll ul x if exitcat==2 & high==1, color(black)) (scatter b x if exitcat==2 & high==1, msymb(circle) mlc(black) mfc(midblue*1.5) msize(small)), norescaling
addplot g1 3: (rcap ll ul x if exitcat==3 & high==0, color(black)) (scatter b x if exitcat==3 & high==0, msymb(circle) mlc(black) mfc(orange*1.5) msize(small)) (rcap ll ul x if exitcat==3 & high==1, color(black)) (scatter b x if exitcat==3 & high==1, msymb(circle) mlc(black) mfc(midblue*1.5) msize(small)), norescaling
addplot g1: , legend(order(6 "Linear combination of coefficient estimates" - " " 1 "Low prior absenteeism" 3 "High prior absenteeism") size(small)) norescaling

restore

**### Figure A4: Effect of Notice of Termination on Absenteeism by Age, Gender, Civil Partnership, and Tenure

*Split by age:
qui gen high_age = 0 if !mi(age)
qui sum age if $sub & reltime_min<-$shift-1 & unique==1, detail
di `r(p50)'
qui replace high_age = 1 if age > `r(p50)' & !mi(age)

*Split by tenure:
qui gen high_tenure_m = 0 if !mi(tenure_m)
forval i=1/3 {
	qui sum tenure_m if $sub & reltime_min<-$shift-1 & unique==1 & exitcat==`i', detail
	di `r(p50)'
	qui replace high_tenure_m = 1 if exitcat==`i' & tenure_m > `r(p50)' & !mi(tenure_m)
}

*Figure:

local split1 high_age
local split2 female
local split3 cipa
local split4 high_tenure_m

forval i=1/3 {
	forval j=1/4 {
		forval k=0/1 {
			qui reghdfe sick $leadslags if $sub & $reltime_bw & reltime_min<-$shift-1 & `split`j''==`k' & exitcat==`i', absorb(empid date) vce(cluster ccenter) noconstant
			
			*Individual coefficients:
			mat A = r(table)
			mat B = (A["b",1...]\A["ll",1...]\A["ul",1...])'
			
			mat C = J(`= rowsof(B)',1,`i')
			mat colnames C = exitcat
			mat D = J(`= rowsof(B)',1,`j')
			mat colnames D = split
			mat E = J(`= rowsof(B)',1,`k')
			mat colnames E = true
			
			mat F_`i'_`j'_`k' = B,C,D,E
			
			*Combined coefficients:
			
			*Anticipation effects:
			local anti_cofs "lead_$shift"
			local anti_cofs_cnt 1
			local max = $shift - 1
			forval l=`max'(-1)1 {
				local anti_cofs `anti_cofs' + lead_`l'
				local anti_cofs_cnt = `anti_cofs_cnt'+1
			}
			qui lincom (`anti_cofs')/`anti_cofs_cnt'
			mat G_`i'_`j'_`k'_anti = r(estimate), r(lb), r(ub), -30, `i', `j', `k'
			
			*Treatment effects:
			local treat_cofs "lag_0"
			local treat_cofs_cnt 1
			forval l=1/$lag_max {
				local treat_cofs `treat_cofs' + lag_`l'
				local treat_cofs_cnt = `treat_cofs_cnt'+1
			}
		
			qui lincom (`treat_cofs')/`treat_cofs_cnt'
			mat G_`i'_`j'_`k'_treat = r(estimate), r(lb), r(ub), 15, `i', `j', `k'
		
			mat G_`i'_`j'_`k' = G_`i'_`j'_`k'_anti\G_`i'_`j'_`k'_treat
			
		}
	}
}

*Combine:

*Individual coefficients:
mat F = F_1_1_0\F_1_1_1\F_1_2_0\F_1_2_1\F_1_3_0\F_1_3_1\F_1_4_0\F_1_4_1\F_2_1_0\F_2_1_1\F_2_2_0\F_2_2_1\F_2_3_0\F_2_3_1\F_2_4_0\F_2_4_1\F_3_1_0\F_3_1_1\F_3_2_0\F_3_2_1\F_3_3_0\F_3_3_1\F_3_4_0\F_3_4_1
*Combined coefficients:
mat G = G_1_1_0\G_1_1_1\G_1_2_0\G_1_2_1\G_1_3_0\G_1_3_1\G_1_4_0\G_1_4_1\G_2_1_0\G_2_1_1\G_2_2_0\G_2_2_1\G_2_3_0\G_2_3_1\G_2_4_0\G_2_4_1\G_3_1_0\G_3_1_1\G_3_2_0\G_3_2_1\G_3_3_0\G_3_3_1\G_3_4_0\G_3_4_1
mat colnames G = b ll ul x exitcat split true

*Split by age:

preserve

clear

svmat F, names(col)

keep if split==1

bys exitcat true: gen x = (_n-1) - ($lead_max + 1)

label define exitcat_label 1 "Dismissal" 2 "Resignation" 3 "Agreement"
label values exitcat exitcat_label

tw (rarea ll ul x if true==0, color(orange%50) lwidth(none)) ///
	(line b x if true==0, lc(orange*1.5)) ///
	(rarea ll ul x if true==1, color(midblue%50) lwidth(none)) ///
	(line b x if true==1, lc(midblue*1.5)), ///
	by(exitcat, rows(1) note("") scale(1.2)) ///
	subtitle(,lc(none) fc(none)) ///
	xtitle("Days since notice", margin(small)) ///
	ytitle("Coefficient estimates" "({&Delta} Probability of being absent)", margin(small)) ///
	xlab(-$lead_max(30)$lag_max, labsize(small)) ///
	xsc(range(-121 31)) ///
	ysc(range(-1 1.25)) ///
	ylab(-1 "-1" -0.75 "-0.75" -0.5 "-0.5" -0.25 "-0.25" 0 "±0" 0.25 "+0.25" 0.5 "+0.5" 0.75 "+0.75" 1 "+1" 1.25 "+1.25", labsize(vsmall)) ///
	xline(-$shift 0, lp(dash)) ///
	yline(0, lp(dash) lc(black)) ///
	yline(-1(0.25)-0.25 0.25(0.25)1.25, lp(dot)) ///
	scheme(s1mono) ///
	xsize(5) ///
	ysize(2) ///
	graphregion(margin(l=0 b=0)) ///
	name(g1, replace)

clear

svmat G, names(col)

keep if split==1

*Shift position of markers:
replace x=x-5 if true==0
replace x=x+5 if true==1

addplot g1 1: (rcap ll ul x if exitcat==1 & true==0, color(black)) (scatter b x if exitcat==1 & true==0, msymb(circle) mlc(black) mfc(orange*1.5) msize(small)) (rcap ll ul x if exitcat==1 & true==1, color(black)) (scatter b x if exitcat==1 & true==1, msymb(circle) mlc(black) mfc(midblue*1.5) msize(small)), norescaling
addplot g1 2: (rcap ll ul x if exitcat==2 & true==0, color(black)) (scatter b x if exitcat==2 & true==0, msymb(circle) mlc(black) mfc(orange*1.5) msize(small)) (rcap ll ul x if exitcat==2 & true==1, color(black)) (scatter b x if exitcat==2 & true==1, msymb(circle) mlc(black) mfc(midblue*1.5) msize(small)), norescaling
addplot g1 3: (rcap ll ul x if exitcat==3 & true==0, color(black)) (scatter b x if exitcat==3 & true==0, msymb(circle) mlc(black) mfc(orange*1.5) msize(small)) (rcap ll ul x if exitcat==3 & true==1, color(black)) (scatter b x if exitcat==3 & true==1, msymb(circle) mlc(black) mfc(midblue*1.5) msize(small)), norescaling
addplot g1: , legend(order(6 "Linear combination of coefficient estimates" - " " 1 "Low age" 3 "High age")) norescaling

restore

*Split by female gender:

preserve

clear

svmat F, names(col)

keep if split==2

bys exitcat true: gen x = (_n-1) - ($lead_max + 1)

label define exitcat_label 1 "Dismissal" 2 "Resignation" 3 "Agreement"
label values exitcat exitcat_label

tw (rarea ll ul x if true==0, color(orange%50) lwidth(none)) ///
	(line b x if true==0, lc(orange*1.5)) ///
	(rarea ll ul x if true==1, color(midblue%50) lwidth(none)) ///
	(line b x if true==1, lc(midblue*1.5)), ///
	by(exitcat, rows(1) note("") scale(1.2)) ///
	subtitle(,lc(none) fc(none)) ///
	xtitle("Days since notice", margin(small)) ///
	ytitle("Coefficient estimates" "({&Delta} Probability of being absent)", margin(small)) ///
	xlab(-$lead_max(30)$lag_max, labsize(small)) ///
	xsc(range(-121 31)) ///
	ysc(range(-1 1.25)) ///
	ylab(-1 "-1" -0.75 "-0.75" -0.5 "-0.5" -0.25 "-0.25" 0 "±0" 0.25 "+0.25" 0.5 "+0.5" 0.75 "+0.75" 1 "+1" 1.25 "+1.25", labsize(vsmall)) ///
	xline(-$shift 0, lp(dash)) ///
	yline(0, lp(dash) lc(black)) ///
	yline(-1(0.25)-0.25 0.25(0.25)1.25, lp(dot)) ///
	scheme(s1mono) ///
	xsize(5) ///
	ysize(2) ///
	graphregion(margin(l=0 b=0)) ///
	name(g1, replace)

clear

svmat G, names(col)

keep if split==2

*Shift position of markers:
replace x=x-5 if true==0
replace x=x+5 if true==1

addplot g1 1: (rcap ll ul x if exitcat==1 & true==0, color(black)) (scatter b x if exitcat==1 & true==0, msymb(circle) mlc(black) mfc(orange*1.5) msize(small)) (rcap ll ul x if exitcat==1 & true==1, color(black)) (scatter b x if exitcat==1 & true==1, msymb(circle) mlc(black) mfc(midblue*1.5) msize(small)), norescaling
addplot g1 2: (rcap ll ul x if exitcat==2 & true==0, color(black)) (scatter b x if exitcat==2 & true==0, msymb(circle) mlc(black) mfc(orange*1.5) msize(small)) (rcap ll ul x if exitcat==2 & true==1, color(black)) (scatter b x if exitcat==2 & true==1, msymb(circle) mlc(black) mfc(midblue*1.5) msize(small)), norescaling
addplot g1 3: (rcap ll ul x if exitcat==3 & true==0, color(black)) (scatter b x if exitcat==3 & true==0, msymb(circle) mlc(black) mfc(orange*1.5) msize(small)) (rcap ll ul x if exitcat==3 & true==1, color(black)) (scatter b x if exitcat==3 & true==1, msymb(circle) mlc(black) mfc(midblue*1.5) msize(small)), norescaling
addplot g1: , legend(order(6 "Linear combination of coefficient estimates" - " " 1 "Male" 3 "Female")) norescaling

restore

*Split by civil partnership:

preserve

clear

svmat F, names(col)

keep if split==3

bys exitcat true: gen x = (_n-1) - ($lead_max + 1)

label define exitcat_label 1 "Dismissal" 2 "Resignation" 3 "Agreement"
label values exitcat exitcat_label

tw (rarea ll ul x if true==0, color(orange%50) lwidth(none)) ///
	(line b x if true==0, lc(orange*1.5)) ///
	(rarea ll ul x if true==1, color(midblue%50) lwidth(none)) ///
	(line b x if true==1, lc(midblue*1.5)), ///
	by(exitcat, rows(1) note("") scale(1.2)) ///
	subtitle(,lc(none) fc(none)) ///
	xtitle("Days since notice", margin(small)) ///
	ytitle("Coefficient estimates" "({&Delta} Probability of being absent)", margin(small)) ///
	xlab(-$lead_max(30)$lag_max, labsize(small)) ///
	xsc(range(-121 31)) ///
	ysc(range(-1 1.25)) ///
	ylab(-1 "-1" -0.75 "-0.75" -0.5 "-0.5" -0.25 "-0.25" 0 "±0" 0.25 "+0.25" 0.5 "+0.5" 0.75 "+0.75" 1 "+1" 1.25 "+1.25", labsize(vsmall)) ///
	xline(-$shift 0, lp(dash)) ///
	yline(0, lp(dash) lc(black)) ///
	yline(-1(0.25)-0.25 0.25(0.25)1.25, lp(dot)) ///
	scheme(s1mono) ///
	xsize(5) ///
	ysize(2) ///
	graphregion(margin(l=0 b=0)) ///
	name(g1, replace)

clear

svmat G, names(col)

keep if split==3

*Shift position of markers:
replace x=x-5 if true==0
replace x=x+5 if true==1

addplot g1 1: (rcap ll ul x if exitcat==1 & true==0, color(black)) (scatter b x if exitcat==1 & true==0, msymb(circle) mlc(black) mfc(orange*1.5) msize(small)) (rcap ll ul x if exitcat==1 & true==1, color(black)) (scatter b x if exitcat==1 & true==1, msymb(circle) mlc(black) mfc(midblue*1.5) msize(small)), norescaling
addplot g1 2: (rcap ll ul x if exitcat==2 & true==0, color(black)) (scatter b x if exitcat==2 & true==0, msymb(circle) mlc(black) mfc(orange*1.5) msize(small)) (rcap ll ul x if exitcat==2 & true==1, color(black)) (scatter b x if exitcat==2 & true==1, msymb(circle) mlc(black) mfc(midblue*1.5) msize(small)), norescaling
addplot g1 3: (rcap ll ul x if exitcat==3 & true==0, color(black)) (scatter b x if exitcat==3 & true==0, msymb(circle) mlc(black) mfc(orange*1.5) msize(small)) (rcap ll ul x if exitcat==3 & true==1, color(black)) (scatter b x if exitcat==3 & true==1, msymb(circle) mlc(black) mfc(midblue*1.5) msize(small)), norescaling
addplot g1: , legend(order(6 "Linear combination of coefficient estimates" - " " 1 "Not in civil partnership" 3 "In civil partnership")) norescaling

restore

*Split by tenure:

preserve

clear

svmat F, names(col)

keep if split==4

bys exitcat true: gen x = (_n-1) - ($lead_max + 1)

label define exitcat_label 1 "Dismissal" 2 "Resignation" 3 "Agreement"
label values exitcat exitcat_label

tw (rarea ll ul x if true==0, color(orange%50) lwidth(none)) ///
	(line b x if true==0, lc(orange*1.5)) ///
	(rarea ll ul x if true==1, color(midblue%50) lwidth(none)) ///
	(line b x if true==1, lc(midblue*1.5)), ///
	by(exitcat, rows(1) note("") scale(1.2)) ///
	subtitle(,lc(none) fc(none)) ///
	xtitle("Days since notice", margin(small)) ///
	ytitle("Coefficient estimates" "({&Delta} Probability of being absent)", margin(small)) ///
	xlab(-$lead_max(30)$lag_max, labsize(small)) ///
	xsc(range(-121 31)) ///
	ysc(range(-1 1.25)) ///
	ylab(-1 "-1" -0.75 "-0.75" -0.5 "-0.5" -0.25 "-0.25" 0 "±0" 0.25 "+0.25" 0.5 "+0.5" 0.75 "+0.75" 1 "+1" 1.25 "+1.25", labsize(vsmall)) ///
	xline(-$shift 0, lp(dash)) ///
	yline(0, lp(dash) lc(black)) ///
	yline(-1(0.25)-0.25 0.25(0.25)1.25, lp(dot)) ///
	scheme(s1mono) ///
	xsize(5) ///
	ysize(2) ///
	graphregion(margin(l=0 b=0)) ///
	name(g1, replace)

clear

svmat G, names(col)

keep if split==4

*Shift position of markers:
replace x=x-5 if true==0
replace x=x+5 if true==1

addplot g1 1: (rcap ll ul x if exitcat==1 & true==0, color(black)) (scatter b x if exitcat==1 & true==0, msymb(circle) mlc(black) mfc(orange*1.5) msize(small)) (rcap ll ul x if exitcat==1 & true==1, color(black)) (scatter b x if exitcat==1 & true==1, msymb(circle) mlc(black) mfc(midblue*1.5) msize(small)), norescaling
addplot g1 2: (rcap ll ul x if exitcat==2 & true==0, color(black)) (scatter b x if exitcat==2 & true==0, msymb(circle) mlc(black) mfc(orange*1.5) msize(small)) (rcap ll ul x if exitcat==2 & true==1, color(black)) (scatter b x if exitcat==2 & true==1, msymb(circle) mlc(black) mfc(midblue*1.5) msize(small)), norescaling
addplot g1 3: (rcap ll ul x if exitcat==3 & true==0, color(black)) (scatter b x if exitcat==3 & true==0, msymb(circle) mlc(black) mfc(orange*1.5) msize(small)) (rcap ll ul x if exitcat==3 & true==1, color(black)) (scatter b x if exitcat==3 & true==1, msymb(circle) mlc(black) mfc(midblue*1.5) msize(small)), norescaling
addplot g1: , legend(order(6 "Linear combination of coefficient estimates" - " " 1 "Low tenure" 3 "High tenure")) norescaling

restore

**### Figure A5: Distribution of Absence Spell Length before and after the Date of Notice

preserve

keep if $sub
keep if $reltime_bw

*Keep only one observation per spell (i.e., first day):
keep if start==1

*Indicate if absence spell falls within notice period:
gen notified=reltime>=0

*Indicate spell length of at least 14 days:
gen len2=len
replace len2=15 if len2>14 & !mi(len2)

*Histogram:
label define exitcat_label 1 "Dismissal" 2 "Resignation" 3 "Agreement"
label values exitcat exitcat_label

tw (hist len2 if notified==0, discrete percent color(orange%50) lwidth(none)) ///
(hist len2 if notified==1, discrete percent color(midblue%50) lwidth(none)), ///
by(exitcat, rows(1) note("")) ///
subtitle(,lc(none) fc(none)) ///
xtitle("Absence spell length", margin(small)) ///
ytitle("Percentage of absence spells", margin(small)) ///
xsc(range(1 15)) ///
ysc(range(0 50)) ///
xlab(, labsize(vsmall)) ///
xlab(1(1)14, custom add) ///
xlab(15 "   >14", custom add) ///
ylab(0(10)50, labsize(small)) ///
yline(0(10)50, lp(dot)) ///
legend(order (1 2) label(1 "Before notice") label(2 "After notice")) ///
scheme(s1mono) ///
xsize(5) ///
ysize(4) ///
graphregion(margin(l=0 b=0))

*Observations:
forval i=1/3 {
	
	di "------------------------------------------"
	di "Type of termination: `i'"
	di "------------------------------------------"
	*Employees:
	qui tab empid if exitcat==`i'
	di "Employees: `r(r)'"
	*Spells:
	forval j=0/1 {
		qui tab empid if exitcat==`i' & notified==`j'
		di "Spells (Notice: `j'): `r(N)'"
	}
}

restore
